<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->

    <section id="main-content">
        <section class="wrapper">
            <h3><i class="fa fa-angle-right"></i> 加盟分类</h3>
            <div class="row mt">
                <div class="col-md-12">
                    <div class="content-panel">
                        <table class="table table-striped table-advance table-hover">
                            <h4><i class="fa fa-angle-right"></i> 加盟分类列表
                                <a href="{:U('type_form',array('currpage'=>$currpage))}" class="btn btn-theme btn-default" style="margin-left: 40px">添加新分类</a></h4>
                            <hr>
                            <thead>
                            <!--<form class="form-inline" role="form" action="{:U('pi')}" method="post">
                                <select class="btn btn-theme04" name="sou"  style="width: 100px;float: left;margin-left: 20px;">
                                    <option value="1">姓名</option>
                                    <option value="2">账号</option>
                                </select>
                                <div class="form-group" style="width: 300px;float: left;overflow: hidden;margin-left: 10px;margin-right: 10px">
                                    <input type="text" name="content" class="form-control"  placeholder="请输入关键字" style="float: left;text-align: center">
                                </div>
                                <input type="submit" class="btn btn-theme" value="搜索" style="float: left" />
                            </form>-->
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>修改时间</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <foreach name="list" item="v">
                            <tr class="parent" id="row_{$v.id}">
                                <td>{$v.id}</td>
                                <td>
                                    <span style="cursor:pointer">{$v.name}</span>
                                </td>
                                <td><if condition="$v['up_at'] != NULL">{$v.up_at|date="Y-m-d H:i:s",###}<else/>无</if></td>
                                <td>{$v.create_at|date="Y-m-d H:i:s",###}</td>
                                <!--<td>
                                    <a href="{:U('type_form',array('id'=>$v['id'],'currpage'=>$currpage))}" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></a>
                                    <if condition="QUAN eq 2">
                                    <button onclick="del({$v.id},17)" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i></button>
                                    </if>
                                </td>-->
                            </tr>
                                <foreach name="v.children" item="va">
                                    <tr class="child_row_{$v.id}">
                                        <td>{$va.id}</td>
                                        <td>
                                            ——{$va.name}
                                        </td>
                                        <td><if condition="$va['up_at'] != NULL">{$va.up_at|date="Y-m-d H:i:s",###}<else/>无</if></td>
                                        <td>{$va.create_at|date="Y-m-d H:i:s",###}</td>
                                        <td>
                                            <a href="{:U('type_form',array('id'=>$va['id']))}" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></a>
                                                <button onclick="del({$va.id},17)" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i></button>
                                        </td>
                                    </tr>
                                </foreach>
                            </foreach>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>
    </section>

</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
    $(function() {
        //    fancybox
        jQuery(".fancybox").fancybox();
    });
</script>
<script>
    //custom select box
    $(function () {
        $('tr.parent').click(function () {
            $(this).siblings('.child_'+this.id ).toggle();
        })
    })
    function del(id,type) {
        var currpage = "{$currpage}";
        if(id > 0){
            layer.confirm('确认要删除该分类吗？删除后不可恢复！', {
                title: '管理员删除提示：',
                btn: ['确定'] //可以无限个按钮
            }, function(index, layero){
                $.ajax({
                    type:"post",
                    data:{id:id,type:type},
                    url:"{:U('Del/del')}",
                    success:function (res) {
                        if(res.status == 1){
                            layer.open({
                                title: '',
                                content: "删除成功",
                            });
                            if(currpage == 1){
                                location.href="__APP__/Dashboard/Join/type";
                            }else{
                                location.href="__APP__/Dashboard/Join/type/currpage/"+currpage;
                            }
                        }
                        if(res.status == 2){
                            layer.open({
                                title: ''
                                ,content: "删除失败"
                            });
                            _pass = false;
                        }
                    }
                })
            });
        }
    }
</script>

</body>
</html>
